package net.towee.client.managers;

import java.util.List;

import net.towee.client.event.core.AccountIdentityUpdatedEvent;
import net.towee.client.event.core.AccountProfileUpdatedEvent;
import net.towee.model.ProfileArea;
import net.towee.model.account.AccountData;
import net.towee.model.account.AccountGroup;
import net.towee.model.account.AccountPermission;

import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * This interface help app to manipulate with current logged in user.
 * In all handlers given method invoke onSuccess with true if operation
 * successfully complited. 
 * 
 * @author c58
 */
public interface AccountHelper {
	/**
	 * Check account permissions in some group
	 * 
	 * @param groupId
	 * @param permissions
	 * @return true if account is owner of group or if have all permissions
	 */
	boolean hasPermissions(String groupId, AccountPermission... permissions);

	/**
	 * @return list of profile areas of logged in account
	 */
	List<ProfileArea> getProfileAreas();

	/**
	 * Check entered user in some group
	 * 
	 * @param groupId
	 * @return true if user entered in group, false othherwise
	 */
	boolean isMemeberOfGroups(String... groupId);

	/**
	 * Get AccountGroup of some groupId
	 * 
	 * @param groupId
	 * @return null if not exists
	 */
	AccountGroup getAccountGroup(String groupId);

	/**
	 * @return AccountData of logged in user
	 */
	AccountData getAccount();

	/**
	 * Apply changes of logged in AccountProfile. If update ok it invoke
	 * handler with true.
	 * 
	 * On success it fire an event {@link AccountProfileUpdatedEvent}
	 * @param handler
	 * @param account
	 */
	void updateAccountProfile(AsyncCallback<Boolean> handler);

	/**
	 * Update account identity
	 * 
	 * On success it fire an event {@link AccountIdentityUpdatedEvent}
	 */
	void updateAccountIdentity(AsyncCallback<Boolean> handler);

	/**
	 * Put setting with given key and value
	 * 
	 * @param key
	 * @param val
	 */
	void putSetting(String key, String val, AsyncCallback<Boolean> handler);

	/**
	 * Update all settings in account
	 */
	void updateSetings(AsyncCallback<Boolean> handler);
	
	void rememberMe();
}
